/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge;

import ru.jSkyRoom.interfaces.JSkyLeveledEntry;
import ru.jSkyRoom.interfaces.Major;
import skyproc.FormID;
import skyproc.LeveledEntry;

/**
 *
 * @author Rakev
 */
public class LeveledEntryBridge extends JSkyBridge<LeveledEntry> implements JSkyLeveledEntry {

    public LeveledEntryBridge(LeveledEntry adapting) {
        super(adapting);
    }

    @Override
    public int getLevel() {
        return getAdapting().getLevel();
    }

    @Override
    public void setLevel(int level) {
        getAdapting().setLevel(level);
    }

    @Override
    public int getCount() {
        return getAdapting().getCount();
    }

    @Override
    public void setCount(int count) {
        getAdapting().setCount(count);
    }

    @Override
    public Major getItem() {
        FormID itemId = getAdapting().getForm();
        return getFinderFactory().createMajorFinder().find(itemId);
    }

    @Override
    public void setItem(Major item) {
        getAdapting().setForm(item.getForm());
    }

    @Override
    public int hashCode() {
        int hashCode = 87;
        hashCode += 87 * getAdapting().getForm().hashCode();
        hashCode += 87 * getAdapting().getCount();
        hashCode += 87 * getAdapting().getLevel();
        return hashCode;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        if (obj.getClass().equals(this.getClass())) {
            final LeveledEntryBridge other = (LeveledEntryBridge) obj;
            if (other.getLevel() != this.getLevel()) {
                return false;
            }
            if (other.getCount() != this.getCount()) {
                return false;
            }
            if (!other.getAdapting().getForm().equals(this.getAdapting().getForm())) {
                return false;
            }
            return true;
        }
        return false;
    }
}
